﻿












//共享、分配
function Save() {
    var objsel = document.getElementById("lstBoxResult");
    var listid = "", allid = "", url = "";
    if (objsel.options.length==0) {
        alert("请选择用户"); 
        //objsel.focus();  
        return;
    }
    for (var i = 0; i < objsel.options.length; i++) {
        listid += objsel.options[i].value + ",";
    }

    var num = document.getElementById("PrivateNum").value;
    if (num == "") {
        alert("请输入设置私海个数");
        //document.getElementById("PrivateNum").focus();
        return;
    }
    if (listid != "") {
        url = "../../Extend/AjaxData/DataProcessin.aspx?action=Save&entity=SetPrivateNum&num=" + num + "&ids=" + listid;
    }
    YAHOO.util.Connect.asyncRequest('POST', url, {
        success: function (res) {
            var inventory;
            try {
                inventory = res.responseText;
                if (inventory == '1') {
                    alert("操作成功!");
                    parent.closeWin();
                    return;
                } else {
                    alert("操作失败");
                }
            }
            catch (e) {
            }
            finally {
            }
        },
        failure: function (error) {
            alert("数据错误：" + error.statusText);
        }
    }, null);

}

//查找按钮事件
function SearchName() {
    var vName = $("#txtSearch").val();
    if (vName != "") {
        document.getElementById('lstBoxSubject').length = 0;
        var url = "../../Extend/AjaxData/CustomOperating.aspx?action=check&entity=V_DatEmployeeForName&id=" + encodeURI(vName);
        YAHOO.util.Connect.asyncRequest('POST', url, {
            success: function (res) {
                var inventory;
                try {
                    inventory = res.responseText;
                    var Employee = [];
                    var obj = eval(inventory);
                    for (var i = 0; i < obj.length; i++) {
                        $('#lstBoxSubject').append('<option value=' + obj[i].UserID + '>' + obj[i].Name + '(' + obj[i].DeptName + ":" + obj[i].EmpCode + ')</option>');
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
    } else {
        $("#txtSearch").focus();
    }
}





//批量新增
var fnResult1 = function () {
    var SetURL = "../../Crm/Customer/SetPrivateNum.aspx?r=";
    var pagetitle = "批量新增";
    document.getElementById("EditUIWindow").src = SetURL + Math.random() + "&title=" + encodeURI(pagetitle);
    YAHOO.example.container.dialog1.show();
    document.getElementById("yui-gen17-button").style.display = "block";
}; 






